<template>
	<view class="tabBar-comp safe-area-inset-bottom flex justify-between">
		<view class="item  flex flex-column align-center justify-center" v-for="(item,index) in tabBarList" :key="item"
			@click="jumpPage(item.pagePath,index)">
			<image v-if="index == tabsStore.current" :src="item.selectedIconPath" mode=""></image>
			<image v-else :src="item.iconPath" mode=""></image>
			<text :class="{'text-active':index == tabBarIndex}">{{item.text}}</text>
		</view>
		<view class="sigin">
			<view class="wrapper" @click="toSignin">
				<view class="content flex flex-column justify-center align-center">
					<image src="../../static/icon/sign.png" mode=""></image>
					<view class="text">签到</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import {
		useTabsStore
	} from '@/stores/tabs'
	const tabsStore = useTabsStore()
	const tabBarIndex = ref(0)
	const tabBarList = ref([{
			"text": "首页",
			"pagePath": "pages/index/index",
			"iconPath": "../../static/icon/index1.png",
			"selectedIconPath": "../../static/icon/index2.png"
		},
		{
			"text": "",
			"pagePath": "pages/signinList/signinList"
			// "iconPath": "",
			// "selectedIconPath": ""
		},
		{
			"text": "我的",
			"pagePath": "pages/my/my",
			"iconPath": "../../static/icon/my1.png",
			"selectedIconPath": "../../static/icon/my2.png"
		},

	])
	const jumpPage = (path, index) => {

		console.log("path----", path);

		uni.redirectTo({
			url: `../../${path}`
		})

		tabBarIndex.value = index
		tabsStore.increment(index)

		console.log("tabBarIndex.value", tabBarIndex.value, index);

	}
	const toSignin = () => {

		uni.navigateTo({
			url: `../../pages/signinList/signinList`
		})
	}
</script>

<style lang="scss" scoped>
	.tabBar-comp {
		position: relative;
	}

	.safe-area-inset-bottom {
		// padding-bottom: env(safe-area-inset-bottom);
		padding-bottom: 30rpx;
	}


	.tabBar-comp {
		box-sizing: border-box;
		padding: 10rpx 80rpx;
		padding-bottom: 30rpx;
		width: 100vw;
		// height: 86rpx;
		background-color: #fff;

		.item {
			width: 20%;

			image {
				height: 48rpx;
				width: 48rpx;
			}

			text {
				margin-top: 6rpx;
				color: #c8c8c8;
				font-size: 20rpx;
			}

			.text-active {
				color: #0162A6;
			}
		}
	}

	.sigin {
		position: absolute;
		left: 50%;
		transform: translateX(-50%);
		bottom: 30rpx;

		.wrapper {
			width: 180rpx;
			height: 180rpx;
			padding: 16rpx;
			background-color: #fff;
			border-radius: 50%;
			box-sizing: border-box;

			.content {
				width: 100%;
				height: 100%;
				background: linear-gradient(to bottom, #afc1ff, #4069ff);
				border-radius: 50%;

				image {
					width: 48rpx;
					height: 64rpx;
					margin-bottom: 4rpx;
				}

				view {
					font-size: 30rpx;
					font-weight: bold;
					color: #fff;
				}
			}
		}
	}
</style>